package com.doodod.common.dao.impl;

import com.doodod.common.dao.GenericDao;
import org.springframework.jdbc.core.JdbcTemplate;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

public class GenericDaoImpl<T, ID extends Serializable>  implements GenericDao<T, ID> {

    private JdbcTemplate jdbcTemplate;

    /**
     * @param jdbcTemplate
     *            the jdbcTemplate to set
     */
    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    public JdbcTemplate getJdbcTemplate() {
        return jdbcTemplate;
    }

    @SuppressWarnings("unchecked")
    protected List<Map<String, Object>> findBySql(String sql, Object[] eterspa,	int[] argTypargTypeses) {
        if (sql == null) {
            return null;
        }
        return jdbcTemplate.queryForList(sql, eterspa, argTypargTypeses);
    }

    protected void executeBySql(final String sql, final Object[] args) {
        getJdbcTemplate().update(sql, args);
    }

    /**
     *  批量入库
     * @param sqlList
     */
    protected void batchUpdate(String[] sqlList){
        getJdbcTemplate().batchUpdate(sqlList);
    }


}